Change dependency tracker to use canonical RRI form - #5776
Draft
backspace wants to merge 4 commits into
Draft
Conversation
Contributor
Host Test Results 1 files 1 suites 1h 46m 23s ⏱️ Results for commit 9eb50bf. Realm Server Test Results 1 files ±0 1 suites ±0 16m 51s ⏱️ - 1m 56s Results for commit 9eb50bf. ± Comparison against earlier commit 359b9a1. |
backspace
force-pushed
the
cs-12212-tracker-rri-native-v2
branch
from
August 17, 2026 13:41
3aa3933 to
7ce848a
Compare
The dependency tracker's `canonicalURL` guard dropped any identifier without an `http(s)` scheme, so prefix-form identifiers could not be tracked at all. Every caller therefore converted to a URL first: `card-api` through `Loader.dependencyTrackingKey`, and the loader internally through `canonicalizeTrackingKey`, which folded each module onto its virtual-alias URL. The forms were then converted back — three of the four snapshot consumers run the deps through `unresolveURLs`, and the index writer folds them again before persisting. The tracker was a URL-form island inside an RRI-form pipeline. Accept both canonical remote forms in the guard instead. A URL starts with `http://`/`https://` and a prefix-form RRI starts with `@`, which distinguishes them without a VirtualNetwork — the same syntactic test `isLocalId` uses — so the tracker stays free of realm mappings. Bare specifiers, relative references and other schemes are still dropped. That lets the conversions go: - `card-api` records `identity.module` and the loader's consumed-module list as they are, both already canonical RRI. - The loader's two internal tracking calls use `moduleCacheKey`, the same fold its module cache uses, so a module's dependency identity and its class identity are one key and cannot diverge. - `dependencyTrackingKey` and `canonicalizeTrackingKey` are removed. Deps on disk are unchanged: they were already normalized to prefix form by the index writer, which now finds them in that form to begin with. The `unresolveURLs` calls at the snapshot consumers are left in place — they also normalize deps from other sources merged into the same arrays. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`moduleCacheKey` folds a module onto its canonical RRI, which is right for a realm reached through a registered prefix but wrong for one that has only a URL mapping: `unresolveURL` maps an alias *to* the real URL and never back, so a module in such a realm was recorded under the host actually serving it rather than the alias the index names it by. In CI that meant a dep on `https://realm-test.ci.localhost/test/person` where every index row says `https://localhost:4202/test/person` — a dep no invalidation scan can match. Give tracking its own fold: canonical RRI when a prefix mapping claims the module, the virtual alias when only a URL mapping does. The module cache keeps `moduleCacheKey`, which needs internal consistency rather than agreement with the index, and the two requirements are not the same. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The dependency walk re-derives a tracking key for every module in a root's transitive set on every import of that root, so a realm's modules are folded repeatedly during a from-scratch index — and the url-mapped branch allocates a URL each time. Cache the result per module identifier. Cleared alongside the other mapping-derived caches when a realm mapping is added or removed, since the key is only stable between those changes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
backspace
force-pushed
the
cs-12212-tracker-rri-native-v2
branch
from
August 17, 2026 20:21
7ce848a to
359b9a1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously it was converting everything to a URL first, now it can handle prefix RRIs.
Claude’s explanation
The dependency tracker's `canonicalURL` guard dropped any identifier without an `http(s)` scheme, so prefix-form identifiers could not be tracked at all. Every caller therefore converted to a URL first: `card-api` through `Loader.dependencyTrackingKey`, and the loader internally through `canonicalizeTrackingKey`, which folded each module onto its virtual-alias URL. The forms were then converted back — three of the four snapshot consumers run the deps through `unresolveURLs`, and the index writer folds them again before persisting. The tracker was a URL-form island inside an RRI-form pipeline.Accept both canonical remote forms in the guard instead. A URL starts with
http:///https://and a prefix-form RRI starts with@, which distinguishes them without a VirtualNetwork — the same syntactic testisLocalIduses — so the tracker stays free of realm mappings. Bare specifiers, relative references and other schemes are still dropped.That lets the conversions go:
card-apirecordsidentity.moduleand the loader's consumed-module list as they are, both already canonical RRI.moduleCacheKey, the same fold its module cache uses, so a module's dependency identity and its class identity are one key and cannot diverge.dependencyTrackingKeyandcanonicalizeTrackingKeyare removed.Deps on disk are unchanged: they were already normalized to prefix form by the index writer, which now finds them in that form to begin with. The
unresolveURLscalls at the snapshot consumers are left in place — they also normalize deps from other sources merged into the same arrays.